package com.freework.report.xmlreport.groupBean.dao;

import java.util.Map;

import com.freework.report.base.service.filterCondition.BuilderFilterConditionSQL;
import com.freework.report.base.service.filterCondition.Condition;
import com.freework.util.unmodifiableMap.KeysIndex;

public class SQLBuilderBean {
	String sql="";
	DBCol []cols=null;
	String []mustParamNames=null;
	Condition[] conditions=null;
	private boolean addwhere=false;
	String byname=null;
	String tablename=null;
	protected KeysIndex keysIndex;

	
	
	
	
	
	
	
	
	public boolean isAddwhere() {
		return addwhere;
	}
	public void setAddwhere(boolean addwhere) {
		this.addwhere = addwhere;
	}
	public Condition[] getConditions() {
		return conditions;
	}
	public void setConditions(Condition[] conditions) {
		this.conditions = conditions;
	}

	public String getSql(BuilderFilterConditionSQL builderCondition,Map paramValues) {
		if(conditions==null){
			return sql.replace("${thisWhereReplace}", "");
		}else{
			String where=builderCondition.getSQL(!addwhere, paramValues, conditions, byname);
			return sql.replace("${thisWhereReplace}", where);

		}
	}
	
	
	public String getTablename() {
		return tablename;
	}
	public void setTablename(String tablename) {
		this.tablename = tablename;
	}
	public KeysIndex getKeysIndex() {
		return keysIndex;
	}
	public void setKeysIndex(KeysIndex keysIndex) {
		this.keysIndex = keysIndex;
	}
	public void setByname(String byname) {
		this.byname = byname;
	}
	public String getByname() {
		return byname;
	}
	public void setSql(String sql) {
		this.sql = sql;
	}
	public DBCol[] getCols() {
		return cols;
	}
	public void setCols(DBCol[] cols) {
		this.cols = cols;
	}
	public String[] getMustParamNames() {
		return mustParamNames;
	}
	public void setMustParamNames(String[] mustParamNames) {
		this.mustParamNames = mustParamNames;
	}
	
	
}
